package environment;

import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Area;
/**
 * This is the environment of the tracking experiment of date 8/10/2011
 * @author Moamen Mokhtar
 *
 */
public class Environment1 extends AbstractEnvironment {

	public Environment1(){
		Polygon ar = new Polygon(new int[]{2,2, 318, 318}, new int[]{2,239,239,2}, 4); // Outer polygon
		area = new Area(ar);
		Rectangle wall = new Rectangle(47, 45, 53, 23); // create an obstacle
		Area w = new Area(wall);
		obstacles.add(w);
		Rectangle wall2 = new Rectangle(251, 74, 55, 20); // create an obstacle
		Area w2 = new Area(wall2);
		obstacles.add(w2);
//		Polygon ar = new Polygon(new int[]{108,210, 73, 237}, new int[]{137,137,239,239}, 4); // Outer polygon
//		area = new Area(ar);
//		Rectangle wall = new Rectangle(119, 60 , 55, 20); // create an obstacle
//		Area w = new Area(wall);
//		obstacles.add(w);
//		Rectangle wall2 = new Rectangle(184, 158, 60, 16); // create an obstacle
//		Area w2 = new Area(wall2);
//		obstacles.add(w2);
		// subtracts obstacles from the main area, works as obstacles
		for (int i = 0; i < obstacles.size(); i++) { 
			area.subtract(obstacles.get(i));
		}
	}
        public void addObstacle(Shape wall){
           Area w = new Area(wall);
           obstacles.add(w);
        }
        
        public Area getFinalArea(){
            for (int i = 0; i < obstacles.size(); i++) { 
			area.subtract(obstacles.get(i));
            }
            return getArea();
        }
        
}
